/***********************************************************************
 * Module:  ControlTaskToInformRuleService.java
 * Author:  Administrator
 * Purpose: Defines the Class ControlTaskToInformRuleService
 ***********************************************************************/

package ishitong.rvims.control.service;

import ishitong.rvims.control.persistence.ControlTaskToInformRuleMapper;
import java.util.HashMap;
import java.util.List;
import ishitong.rvims.domain.inform.InformRule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/** @pdOid c2413991-e9bd-4614-8c53-4a8770bf96dc */
@Service
public class ControlTaskToInformRuleService {
   /** @pdOid 9809f58f-9cf7-4e25-b82e-d5718401adbc
       @pdRoleInfo migr=yes name=ControlTaskToInformRuleMapper assc=association9 */
   @Autowired
   private ControlTaskToInformRuleMapper controlTaskToInformRule;
   
   /** @param controlTaskId
    * @pdOid 2ccb3f07-5e7c-4d7a-8340-58759806f731 */
   public void deleteInformRuleByControlTaskId(String controlTaskId) {
      // TODO: implement
    controlTaskToInformRule.deleteInformRuleByControlTaskId(controlTaskId);
   }
   
   /** @param controlTaskIds 
    * @param informRuleIds
    * @pdOid dcf0bad4-28bc-4157-9efa-4fc335e3c311 */
   public void updateControlTaskToInformRule(String[] controlTaskIds, String[] informRuleIds) {
      // TODO: implement
    HashMap<String,Integer> cphm = new HashMap<String,Integer>();
    for(int i = 0 ; i < controlTaskIds.length ; i ++)
    {
     for (int j = 0 ; j < informRuleIds.length ; j ++)
     {
   	  cphm.put("ID", Integer.parseInt(controlTaskIds[i]));
   	  cphm.put("T_I_ID", Integer.parseInt(informRuleIds[j]));
   	  controlTaskToInformRule.insertControlTaskToInformRule(cphm);
     }
    }
   }
   
   /** @param controlTaskId
    * @pdOid 7b4e539a-7ba9-4354-a2ab-613f6af7c719 */
   public List<InformRule> findInformRuleByControlTaskId(String controlTaskId) {
      // TODO: implement
      return controlTaskToInformRule.selectInformRuleByControlTaskId(controlTaskId);
   }

}